The software system responsible for managing and storing file information in an operating system is called a file management system, which is briefly known as a file system. From the perspective of the system, a file system is a system for organizing and allocating file storage space (for example, a hard disk, a disk or a partition), storing files, and protecting and retrieving stored files. Specifically, the file system is responsible for creating a file for a user, storing, reading, modifying and dumping files, controlling file access, and canceling the file when the user does not use it any longer.
Before being used as a file system, a disk or partition needs to be initialized, and the recorded data structures need to be written onto the disk. This process is referred to as creating a file system. After the file system is created, the storage space of the disk or partition is divided into multiple file system blocks (that is, disk space blocks) of a specific size for storing files.
Currently, when writing files, the file system allocates file system blocks to each of the files independently to store the file. As shown in FIG. 1, for the purpose of storing a file, more file system blocks are allocated to a large file (that is, a file of a larger size), and fewer file system blocks are allocated to a small file (that is, a file of a smaller size). At the time of writing files with different sizes, the files are written into positions of the file system blocks allocated to the files respectively. Moreover, the positions of the file system blocks allocated to the files are random, and therefore, the write positions of the files are irregular.
In some scenarios such as a cloud storage system, a file system needs to store massive files with different sizes. When the file system processes massive files with different sizes, especially massive small files, because the write positions of the massive files with different sizes are irregular, when the file system writes massive files with different sizes, the magnetic head keeps moving from one position to another. It takes a long time to move the magnetic head position, which seriously affects the write speed of the file system and leads to poor write performance of the file system.